package com.situ.blog.service.impl;

import com.situ.blog.dao.IBlogTypeDao;
import com.situ.blog.dao.impl.BlogTypeDaoImpl;
import com.situ.blog.pojo.entity.BlogType;
import com.situ.blog.pojo.query.BlogTypeQuery;
import com.situ.blog.service.IBlogTypeService;
import com.situ.blog.util.PageInfo;

import java.util.List;

public class BlogTypeServiceImpl implements IBlogTypeService {
    private IBlogTypeDao blogTypeDao = new BlogTypeDaoImpl();

    @Override
    public PageInfo selectByPage(BlogTypeQuery blogTypeQuery) {

        List<BlogType> list = blogTypeDao.selectByPage(blogTypeQuery);
        int totalCount = blogTypeDao.selectTotalCount(blogTypeQuery);

        return PageInfo.ok(totalCount,list);
    }

    @Override
    public void deleteAll(String[] ids) {
        for (String id : ids) {
            blogTypeDao.deleteById(Integer.parseInt(id));
        }
    }

    @Override
    public void add(BlogType blogType) {
        blogTypeDao.add(blogType);
    }

    @Override
    public void deleteById(int id) {
        blogTypeDao.deleteById(id);
    }

    @Override
    public BlogType seleteById(int id) {
        return blogTypeDao.seleteById(id);
    }

    @Override
    public void update(BlogType blogType) {
        blogTypeDao.update(blogType);
    }

    @Override
    public List<BlogType> selectAll() {
        return blogTypeDao.selectAll();
    }
}
